<?php
namespace jy_aligroup;
defined('BY_JYA') or exit('error');
/*
	消息提醒
*/
class notice extends \plugin{
	public function notice_send2buyer($order,$url=''){
		//发送订单发货通知给买方
		$template_id=cfc('account')->get_tpl_template_id('OPENTM202243318','订单发货通知');
		if($_SESSION['wxapp_id']){
			$wxapptemplate_id=cfc('wxapp_api')->get_tpl_template_id('3534',[1,2,3,4],'send2buyer','订单支付成功通知','jy_weishop');
		}	
		$address_str=model('core/member')->get_address_str($order['addressid']);
		$message=array(
			'first'=>array('value'=>'您的商品已发货，请及时查收！',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$order['ordersn'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>$this->express_types[$order['express']['express_id']]['name'],"color" => "#4a5077"),
			'keyword3'=>array('value'=>$order['express']['expresssn'],"color" => "#4a5077"),
			'keyword4'=>array('value'=>$address_str,"color" => "#4a5077"),
			'remark'=>array('value'=>'请耐心等候！',"color" => "#4a5077"),
		);
		$wxappmsg=array(
			array('value'=>$order['ordersn']),
			array('value'=>'已发货'),
			array('value'=>$order['goods']['0']['title']),
			array('value'=>price($order['price'])),
		);
		if(!$url){
			$url=custom_url('jy_aligroup/orderdetail//id='.$order['id'],true);
		}
		cfc('account')->sendtwoNotice($order['mid'],$template_id,$message,$url,'send2buyer','jy_weishop',$order['id']);
		if($_SESSION['wxapp_id']){
			$template_id=cfc('wxapp_api')->checktplNotice($order['mid'],$wxapptemplate_id,$wxappmsg,$url,'send2buyer','jy_weishop',$order['id']);
		}
	}
	public function notice_vsend2buyer($order,$url=''){
		//卡密自动发货通知发送订单发货通知给买方
		$template_id=cfc('account')->get_tpl_template_id('OPENTM207793687','自动发货通知');
		$remark="发货信息：\n";
		$remark .='联系人：'.$order['nickname']."\n";
		$remark .='联系手机：'.$order['mobile']."\n";
		//$remark .=$order['virtualinfo'];
		$message=array(
			'first'=>array('value'=>'您的商品已发货，请及时查收！',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$order['goods']['0']['title'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>$order['ordersn'],"color" => "#4a5077"),
			'keyword3'=>array('value'=>$order['price'],"color" => "#4a5077"),
			'keyword4'=>array('value'=>$order['virtualinfo'],"color" => "#4a5077"),
			'remark'=>array('value'=>$remark,"color" => "#4a5077"),
		);
		if(!$url){
			$url=custom_url('jy_aligroup/orderdetail//id='.$order['id'],true);
		}
		cfc('account')->sendtwoNotice($order['mid'],$template_id,$message,$url,'vsend2buyer','jy_weishop',$order['id']);
	}
}
